﻿using System;
using System.Configuration;
using System.IO;
using Sustainalytics.OS;

namespace Sustainalytics.ESGComputing.Launcher
{
    static class ProgramConsole
    {
        public static void Start(string [] args)
        {
            try
            {
                var childProcessPath = ConfigurationManager.AppSettings["ChildProcessPath"];

                var cmd = Path.Combine(Utils.GetCurrentAssemblyDir(), childProcessPath);

                Console.WriteLine("starting process:\"{0}\"", cmd);

                using (var process = LinkedProcess.Start(cmd, true, false))
                {
                    process.WaitForExit();
                    Console.WriteLine("Child completed");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.ReadKey();
            }
        }
    }
}
